import { request, formRequest } from '../utils/request';

export async function fetchContentList(params) {
  return request('prodapi/goods/getGoodsInfoList', {
    method: 'POST',
    body: params,
  });
}

export async function fetchGoodsDetail(params) {
  return request('prodapi/goods/getGoodsInfoDetail', {
    method: 'POST',
    body: params,
  });
}


export async function addContent(params) {
  let file = params.name;
  delete params.name;
  delete params.amount;
  delete params.authorName;
  console.log(params)
  return formRequest('prodapi/goods/upload/addGoodsInfo', {
    method: 'POST',
    body: params,
  },
    file
  );
}

export async function editContent(params) {
  let file = params.name;
  delete params.name;
  delete params.amount;
  delete params.authorName;

  return formRequest('prodapi/goods/upload/updateGoodsInfo', {
    method: 'POST',
    body: params,
  },
    file
  );
}


export async function upGoodsList(params) {
  return request('prodapi/goods/upGoodsList', {
    method: 'POST',
    body: params,
  });
}

export async function downGoodsList(params) {
  return request('prodapi/goods/downGoodsList', {
    method: 'POST',
    body: params,
  });
}

export async function delGoodsList(params) {
  return request('prodapi/goods/delGoodsList', {
    method: 'POST',
    body: params,
  });
}

export async function addBooklet(params) {
  let file = params.name;
  return formRequest('prodapi/goods/upload/addContentBooklet', {
    method: 'POST',
    body: params,
  },
    file
  );
}

export async function editBooklet(params) {
  let file = params.name;
  return formRequest('prodapi/goods/upload/updateContentBooklet', {
    method: 'POST',
    body: params,
  },
    file
  );
}

export async function fetchChannelList(params) {
  return request('adminapi/prod/getChannelInfoList', {
    method: 'POST',
    body: params,
  });
}

export async function addChannel(params) {
  let file = params.name;
  delete params.name;
  return formRequest('adminapi/prod/upload/addChannelInfo', {
    method: 'POST',
    body: params,
  },
    file
  );
}

export async function updateChannel(params) {
  let file = params.name;
  delete params.name;
  return formRequest('adminapi/prod/upload/updateChannelInfo', {
    method: 'POST',
    body: params,
  },
    file
  );
}

export async function deleteChannel(params) {
  return request('adminapi/prod/delChannelInfo', {
    method: 'POST',
    body: params,
  });
}

export async function fetchChannelTree(params) {
  return request('adminapi/prod/getChannelInfoTree', {
    method: 'POST',
    body: params,
  });
}

export async function addAuthor(params) {
  let file = params.name;
  delete params.name;
  return formRequest('adminapi/prod/upload/addAuthorInfo', {
    method: 'POST',
    body: params,
  },
    file
  );
}

export async function updateAuthor(params) {
  let file = params.name;
  delete params.name;
  return formRequest('adminapi/prod/upload/updateAuthorInfo', {
    method: 'POST',
    body: params,
  },
    file
  );
}

export async function deleteAuthor(params) {
  return request('adminapi/prod/delAuthorInfo', {
    method: 'POST',
    body: params,
  });
}

export async function changeAuthorStatus(params) {
  return request('adminapi/prod/batchUpdateAuthorSts', {
    method: 'POST',
    body: params,
  });
}



export async function fetchTagList(params) {
  return request('adminapi/prod/getLabelInfoList', {
    method: 'POST',
    body: params,
  });
}

export async function addTag(params) {
  return request('adminapi/prod/addLabelInfo', {
    method: 'POST',
    body: params,
  });
}

export async function deleteTag(params) {
  return request('adminapi/prod/delContentLabelInfo', {
    method: 'POST',
    body: params,
  });
}

export async function editTag(params) {
  return request('adminapi/prod/updateLabelInfo', {
    method: 'POST',
    body: params,
  });
}

export async function fetchAuthorList(params) {
  return request('adminapi/prod/getAuthorInfoList', {
    method: 'POST',
    body: params,
  });
}




